﻿var catalogData = [
    { href: "#", src: "/Content/Images/catalog/myhome.png", text: "我的ShopNum1", type: "myhome" },
    { href: "#", src: "/Content/Images/catalog/categorys.png", text: "商品分类", type: "categorys" },
    { href: "#", src: "/Content/Images/catalog/collect.png", text: "我的收藏", type: "collect" },
    { href: "#", src: "/Content/Images/catalog/message.png", text: "站内消息", type: "message" },
    { href: "#", src: "/Content/Images/catalog/ebook.png", text: "购物车", type: "buyer" },
    { href: "#", src: "/Content/Images/catalog/band.png", text: "我的订单", type: "order" }
];

window.Catalog = Backbone.Model.extend({
    defaults: {
        href: "#",
        src: "/Content/Images/catalog/myhome.png",
        text: "我的ShopNum1"
    }
});

window.CatalogCollection = Backbone.Collection.extend({
    model: Catalog
});

window.CatalogView = Backbone.View.extend({
    el: "#jqt",
    initialize: function () {
        this.collection = new CatalogCollection(catalogData);
        this.template = $('#IndexCatalogTemplate').html();
    },
    render: function () {
        var partial = { header: $('#HeaderTemplate').html(), footer: $('#FooterTemplate').html(), innerFooter: $('#InnerFooterTemplate').html() };
        var data = { hasLogo: true, btnListR: [{ name: 'avatar' }, { name: 'cart'}], btnListL: [{ name: 'sort'}],
            list: this.collection.toJSON()
        };

        this.$el.append(Mustache.render(this.template, data, partial));

        new Plugins.SearchPlugin('#Catalog .searchContainer', {
            id: 'keyword_catalog',
            isGlobalSearch:true
        });

        return this;
    }
});